package com.aWei.springbootinit.controller;

import com.aWei.springbootinit.common.BaseResponse;
import com.aWei.springbootinit.common.ResultUtils;
import com.aWei.springbootinit.manager.SearchFacade;

import com.aWei.springbootinit.model.dto.search.SearchRequest;
import com.aWei.springbootinit.model.vo.SearchVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 聚合接口，接口在这里统一管理，几乎没有并发限制，浏览器平均一次调用6个请求
 *
 * @author 小维哥
 * @version 1.2
 */

@RestController
@RequestMapping("/search")
@Slf4j
public class SearchController {


        @Resource
        private SearchFacade searchFacade;

        //后端所有接口的统一管理方法（门面模式）
        @PostMapping("/all")
        public BaseResponse<SearchVO> searchAll(@RequestBody SearchRequest searchRequest, HttpServletRequest request) {
                return ResultUtils.success(searchFacade.searchAll(searchRequest, request));
        }
}

